package com.easy.service.impl;

import com.easy.bean.OperationLog;
import com.easy.mapper.OperationLogDao;
import com.easy.service.OperationLogService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class OperationLogServiceImpl implements OperationLogService {
    
    @Autowired
    private OperationLogDao operationLogDao;
    
    @Override
    public OperationLog add(OperationLog log) {
        operationLogDao.add(log);
        return operationLogDao.findById(log.getId());
    }
    
    @Override
    public int del(Integer id) {
        return operationLogDao.del(id);
    }
    
    @Override
    public List<OperationLog> findAll() {
        return operationLogDao.findAll();
    }
    
    @Override
    public OperationLog findById(Integer id) {
        return operationLogDao.findById(id);
    }
    
    @Override
    public void page(Page page) {
        // 获取总记录数
        int count = operationLogDao.count();
        page.setCount(count);

        // 获取分页数据
        List<OperationLog> data = operationLogDao.page(page.getStart(), page.getLimit());
        page.setData(data);
    }
}